<template>
  <j-modal
    title="招标公告"
    :width="1200"
    :visible="visible"
    switchFullscreen
    :fullscreen="true"
    :maskClosable="false"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <!--    <a-card :bordered="false">
      &lt;!&ndash; 查询区域 &ndash;&gt;
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="招标项目编号">
                {{ projectInfo.projectCode }}
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="招标项目名称">
                {{ projectInfo.projectName }}
              </a-form-item>
            </a-col>
            <template v-if="toggleSearchStatus">
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="招标编号">
                  <a-input placeholder="请输入招标编号" v-model="queryParam.tenderCode"></a-input>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="公告标题">
                  <a-input placeholder="请输入公告标题" v-model="queryParam.noticeName"></a-input>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="状态">
                  <j-dict-select-tag
                    placeholder="请选择状态"
                    v-model="queryParam.status"
                    dictCode="sys_common_status"
                  />
                </a-form-item>
              </a-col>
            </template>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                <a-button @click="handleAdd" type="primary" icon="plus" style="margin-left: 8px">新增</a-button>
                <a @click="handleToggleSearch" style="margin-left: 8px">
                  {{ toggleSearchStatus ? '收起' : '展开' }}
                  <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      &lt;!&ndash; 查询区域-END &ndash;&gt;

      <div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap"
          :scroll="{ x: true }"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          @change="handleTableChange"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text, record">
            <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
            <img
              v-else
              :src="getImgView(text)"
              :preview="record.id"
              height="25px"
              alt=""
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
              下载
            </a-button>
          </template>
          <span slot="action" slot-scope="text, record">
            <template v-if="record.status == 0 || record.status == 3">
              <a-divider type="vertical" />
              <a @click="handleEdit(record)">编辑</a>

              <a-divider type="vertical" />
              <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(record)">
                <a>提交</a>
              </a-popconfirm>
            </template>
            <a v-else @click="handleDetail(record)">详情</a>
          </span>
        </a-table>
      </div>

      <ex-tender-ann-qua-inquery-ann-modal ref="modalForm" @ok="modalFormOk" />
    </a-card>-->
    <NoticeList :projectInfo="projectInfo" :projectId="projectInfo.projectId" />
  </j-modal>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ExTenderAnnQuaInqueryAnnModal from './modules/ExTenderAnnQuaInqueryAnnModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import '@/assets/less/TableExpand.less'
import { httpAction, getAction } from '@/api/manage'
import NoticeList from './modules/NoticeList.vue'

export default {
  name: 'ExTenderAnnQuaInqueryAnnList',
  mixins: [JeecgListMixin],
  components: {
    ExTenderAnnQuaInqueryAnnModal,
    NoticeList,
  },
  data() {
    return {
      description: '招标公告',
      title: '',
      width: 800,
      visible: false,
      url: {
        list: '/exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/list',
        delete: '/exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/delete',
        deleteBatch: '/exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/deleteBatch',
        exportXlsUrl: '/exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/exportXls',
        importExcelUrl: 'exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/importExcel',
        submitAudit: 'exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn//submitAudit',
      },
      dictOptions: {},
      superFieldList: [],
      projectInfo: {},
    }
  },
  created() {},
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
    handleCancel() {
      this.close()
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {},
    edit(record) {
      debugger
      this.visible = true
      this.projectInfo = Object.assign({}, record)
      this.loadData(1)
    },
    handleAdd: function () {
      this.$refs.modalForm.add(this.projectInfo)
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    },
    handleSubmit(row) {
      var that = this
      httpAction(this.url.submitAudit + '?id=' + row.id, row, 'post')
        .then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData()
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.confirmLoading = false
        })
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      if (this.projectInfo.projectId == '') {
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams() //查询条件
      params['projectId'] = this.projectInfo.projectId
      this.loading = true
      getAction(this.url.list, params)
        .then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.ipagination.total = res.result.total
            } else {
              this.ipagination.total = 0
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
